package com.mars.nacos.api.controller;

import com.mars.nacos.api.dto.response.UserInfoResDTO;
import com.mars.nacos.domain.service.UserAppApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author : kyrie
 * @date : 2022/8/23 15:50
 * #desc    : some description
 */
@Api(tags = "用户中心API")
@RestController
@RequestMapping("/user")
@Slf4j
@RefreshScope
public class UserAppController {

    @Value("${user.prefix}")
    private String userNamePrefix;
    @Resource
    private UserAppApiService userAppApiService;

    @ApiOperation(value = "获取用户昵称", notes = "获取用户昵称")
    @GetMapping("/v1/username")
    public UserInfoResDTO getUserName() {
        log.info("查询用户昵称公共前缀为: prefix={}", userNamePrefix);

        return userAppApiService.getUserInfo();
    }
}
